/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaces;

import exceptions.MyIndexOutOfBoundsException;
import mylist.MyListIterator;

/**
 *
 * @author Daryna_Ragimova
 */
public interface MyList<E> extends  Iterable<E>{
    /**
     * Appends the specified element to the end of this list
     * @param e - element to be appended to this list
     * @return true
     */
    void add(E e);
    /**
     * Inserts the specified element at the specified position in this list (optional operation). 
     * Shifts the element currently at that position (if any) and any subsequent elements to the 
     * right (adds one to their indices).
     * @param index - index at which the specified element is to be inserted
     * @param element - element to be inserted
     */
    void add(int index,E element)throws MyIndexOutOfBoundsException;
    /**
     * Appends all of the elements in the specified collection to the end of this list,
     * in the order that they are returned by the specified collection's iterator .
     * @param c - collection containing elements to be added to this list
     */
    void addAll(E[] c);
    /**
     * nserts all of the elements in the specified collection into this list at the specified position 
     * @param index - index at which to insert the first element from the specified collection
     * @param c collection containing elements to be added to this list
     */
    void addAll(int index, E[] c)throws MyIndexOutOfBoundsException;
    /**
     * Returns the element at the specified position in this list.
     * @param index - index of the element to return
     * @return the element at the specified position in this list
     */
    E get(int index)throws MyIndexOutOfBoundsException;
    /**
     * Removes the element at the specified position in this list (optional operation).
     * Shifts any subsequent elements to the left (subtracts one from their indices).
     * @param index - the index of the element to be removed
     * @return the element that was removed from the list
     */
    E remove(int index)throws MyIndexOutOfBoundsException;
    /**
     * Removes all of the elements from this list (optional operation). The list will be empty after this call returns.
     */
    void clear();
    /**
     * checks is the list is empty
     * @return true if this list contains no elements.
     */
    boolean isEmpty();
    /**
     * Replaces the element at the specified position in this list with the specified element 
     * @param index - index of the element to replace
     * @param e - element to be stored at the specified position
     */
    void set(int index, E e);
    
    /**
     * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. 
     * @param o-element to search for
     * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element
     */
    int indexOf(Object o); 
    /**
     * Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.
     * @return the number of elements in this list
     */
    int size(); 
    /**
     * Returns an array containing all of the elements in this list in proper sequence (from first to last element).
     * The returned array will be "safe" in that no references to it are maintained by this list.
     * @return an array containing all of the elements in this list in proper sequence
     */
    Object[] toArray();
    /**
     * 
     * @return an iterator over the elements in this list in proper sequence
     */
    
    MyListIterator iterator();
    
    MyListIterator iterator(int index);
}
